<template>
	<view style="background-color: #fff;margin-top: 40rpx;">
		<swiper class="swiper" style="height: 120rpx;" indicator="false" circular>
			<swiper-item>
				<u-grid :border="false" col="4">
					<u-grid-item v-for="(listItem,listIndex) in list1" :key="listIndex" @click="grid1(listIndex)">
						<image :src="listItem.name" style="width: 30px;height: 30px;"></image>
						<text class="grid-text">{{listItem.title}}</text>
					</u-grid-item>
				</u-grid>
			</swiper-item>
			<swiper-item v-if="user.frentLink!==5&&user!==''">
				<u-grid :border="false" col="4" v-if="user.frentLink!==5&&user!==''">
					<u-grid-item v-for="(listItem,listIndex) in list2" :key="listIndex" @click="grid2(listIndex)">
						<image :src="listItem.name" style="width: 30px;height: 30px;"></image>
						<text class="grid-text">{{listItem.title}}</text>
					</u-grid-item>
				</u-grid>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		name: "swiper",
		data() {
			return {
				user:uni.getStorageSync("user"),
				userId: uni.getStorageSync("user").frentLink,
				list1: [{
						name: '/static/icon_info/账单.png',
						title: '秒速记账'
					},
					{
						name: '/static/icon_info/文章.png',
						title: '煋玥文章'
					},
					{
						name: '/static/icon_info/链接.png',
						title: '友情链接'
					},
					{
						name: '/static/icon_info/相册.png',
						title: '新建相册'
					},
				],
				list2: [{
						name: '/static/icon/图片.png',
						title: '上传图片'
					},
					{
						name: '/static/icon_info/日记.png',
						title: '发动态'
					},
					{
						name: '/static/icon_info/链接.png',
						title: '发友链'
					},
					{
						name: '/static/icon_info/个人中心.png',
						title: '用户管理'
					},
				],
			};
		},
		methods: {
			async grid1(index) {
				if (index === 0) {
					uni.navigateTo({
						url: "/pagesa/accountAdd/accountAdd"
					})
				} else if (index === 1) {
					uni.navigateTo({
						url: '/pagesa/airtle/airtle'
					})
				} else if (index === 2) {
					uni.navigateTo({
						url: '/pagesa/frentLink/frentLink'
					})
				} else {
					if (this.userId ===5) {
						return uni.showToast({
							title: '无权操作,联系客服开通权限',
							icon:"none"
						})
					}
					uni.navigateTo({
						url: '/pagesa/loadPic/loadPic'
					})
				}
			},
			async grid2(index) {
				if (index === 0) {
					uni.navigateTo({
						url: "/pagesa/loadPicture/loadPicture"
					})
				} else if (index === 1) {
					uni.navigateTo({
						url: '/pagesa/dongTai/dongTai'
					})
				} else if (index === 2) {
					if (this.userId === 0 || this.userId === 2 || this.userId === 5) {
						return uni.showToast({
							title: '无权操作',
							icon:"none"
						})
					}
					uni.navigateTo({
						url: '/pagesa/sentFrentLink/sentFrentLink'
					})
				} else {
					if (this.userId !==1) {
						return uni.showToast({
							title: '无权操作',
							icon:"none"
						})
					}
					uni.navigateTo({
						url: '/pagesa/users/users'
					})
				}
			}
		}
	}
</script>

<style>

</style>
